using System.Web.UI;
using Microsoft.SharePoint.Utilities;

namespace BilSimser.SharePoint.Common.Controls
{
	public class OWSLabelField : OWSBase
	{
		#region Construction

		/// <summary>
		/// default constructor
		/// </summary>
		public OWSLabelField()
		{
		}

		#endregion

		#region properties

		/// <summary>
		/// The text of the control
		/// </summary>
		public override string Text
		{
			get { return ViewState["Text"] as string; }
			set { ViewState["Text"] = value; }
		}

		#endregion

		#region overridden methods

		/// <summary>
		/// Renders the contents of the controls
		/// </summary>
		/// <param name="wtr">the HTML write to which to output.</param>
		protected override void Render (HtmlTextWriter wtr)
		{
			wtr.Write(
				"<span class=\"ms-WPBody\">{1}</span>" +
					"<input type=\"hidden\" id=\"{0}\" name=\"{0}\" value=\"{2}\">",
				UniqueID,
				(Text == null) ? JavaScriptValue : Text,
				SPEncode.HtmlEncode(Value)
				);
		}

		#endregion
	}
}